﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
using System.IO;

namespace ConsoleApplication1
{
    class Sha1BinaryFilesTest
    {
        static void CreateBinaryFile()
        {
            BinaryWriter outputFile = new BinaryWriter(File.Open("binaryFile.bin", FileMode.OpenOrCreate));

            using (outputFile)
            {
                outputFile.Write("pesho");
                outputFile.Write(5);
            }
        }

        static byte[] ReadBinaryFile()
        {
            BinaryReader inputFile = new BinaryReader(File.Open("binaryFile.bin", FileMode.Open));

            byte[] buffer = new byte[4096];
            SHA1 sha1 = SHA1.Create();
            using (inputFile)
            {
                inputFile.Read(buffer, 0, 4096);
                sha1.ComputeHash(buffer);
            }

            return sha1.Hash;
        }

        static void Main(string[] args)
        {
            

            byte[] fileBytes =ReadBinaryFile();

            foreach (var byteInFile in fileBytes)
            {
                Console.WriteLine(byteInFile);
            }
        }
    }
}
